﻿@model SAIM.Models.TicketData
@using MvcFileUploader.HtmlHelper
@using MvcFileUploader.Models
@{
    ViewBag.Title = "Ticket : Archivos adjuntos";
    //option for inline view only
    var ui = "jquery".Equals(Request.Params["ui"]) ? UploadUI.JQueryUI : UploadUI.Bootstrap;
    var toggleUi = ui == UploadUI.Bootstrap ? "jquery" : "bootstrap";
}

<div class="page-header">
    <h2>@ViewBag.Title</h2>
    <p class="text-success">@ViewBag.StatusMessage</p>
</div>
<div class="panel panel-default table-responsive">
    <ul class="list-group col-md-6" style="padding-left:15px;">
        <li class="list-group-item list-group-item-text"><b>Información del ticket</b> [ <a href="@Url.Action("Summary", "Tickets", new { id = Model.IdTicket })">Regresar</a> ]</li>
        <li class="list-group-item" style="border-bottom: none;">
            <dl class="dl-horizontal">
                <dt>Número de ticket:</dt>
                <dd>@Model.IdTicket</dd>
            </dl>
            <dl class="dl-horizontal">
                <dt>Área:</dt>
                <dd>@Model.Area</dd>
            </dl>
            <dl class="dl-horizontal">
                <dt>Servicio:</dt>
                <dd>@Model.Issue</dd>
            </dl>
            <dl class="dl-horizontal">
                <dt>Fecha y hora:</dt>
                <dd>@Model.TicketDate</dd>
            </dl>
        </li>
    </ul>
    <ul class="list-group col-md-6" style="padding-left:15px;">
        <li class="list-group-item list-group-item-text" style="border-top: none;"><b>Información del usuario</b></li>
        <li class="list-group-item">
            <dl class="dl-horizontal">
                <dt>Usuario:</dt>
                <dd>@Model.UserName</dd>
            </dl>
            <dl class="dl-horizontal">
                <dt>UPN:</dt>
                <dd>@Model.RPE</dd>
            </dl>
            <dl class="dl-horizontal">
                <dt>Correo electrónico:</dt>
                <dd>@Model.Email</dd>
            </dl>
            <dl class="dl-horizontal">
                <dt>Perfil:</dt>
                <dd>@Model.Profile</dd>
            </dl>
        </li>
    </ul>
</div>
<div class="panel panel-default">
    <div class="table-responsive">
        <table id="grid-data" class="table table-striped">
            <thead>
                <tr>
                    <th data-column-id="Options" data-formatter="link">Opciones</th>
                    <th data-column-id="FileName">Archivo</th>
                    <th data-column-id="FileSize">Tamaño</th>
                    <th data-column-id="UserName">Usuario</th>
                    <th data-column-id="CreationDate">Fecha de modificación</th>
                </tr>
            </thead>
        </table>
    </div>
</div>

@if(!Model.Closed)
{ 
    <div class="well">
        <legend>Adjuntar archivos</legend>
        <p class="help-block">Formatos permitidos: gif, jpg, jpeg, tiff, png, pdf, doc, docx, xls, xlsx, xml, txt</p>
        @(
            Html.MvcFileUpload()
            .UploadAt(Url.Action("UploadFile"))
            .UIStyle(ui)
            .WithFileTypes(@"/(\.|\/)(gif|jpe?g|tiff|png|pdf|docx?|xlsx?|xml|txt)$/i")
            .WithMaxFileSize(10000000)
            .AddFormField("Id", Model.IdTicket.ToString())
            .DisableImagePreview()
            .RenderInline("_MvcFileupload")
        )

    </div>
}

<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog" data-url="@Url.Action("_GetEditionsByComment", "Tickets")"></div>

@section Scripts {
    <script type="text/javascript">
        urlEditions = '@Url.Action("_GetFileEditions", "Tickets", new { @id = Model.IdTicket })';
        urlFiles = '@Url.Action("GetTicketAttachments", "Tickets", new { id = Model.IdTicket })';
        function getColumn(column, row) {
            var components = '<div style="float: left; padding: 4px 4px 4px 5px;" title="Descargar"><a href=\"' + '@Url.Action("GetAttachedFile", "Tickets")/@Model.IdTicket?attachmentId=' + row.Mask + '" role="button" class="btn btn-primary">' +
                        '<span class="glyphicon glyphicon-arrow-down" aria-hidden="true"></span></a></div>';
            if (row.HasEditions) {
                components += '<div style="float: left; padding: 4px 4px 4px 5px;" title="Historial de ediciones">' +
                                    '<button type="button" class="CommentHistory btn btn-primary" data-filename="' + row.FileName + '">' +
                                        '<span class="glyphicon glyphicon-time" aria-hidden="true"></span></button></div>';
            }
            return components;
        }
    </script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/Tickets/Attachments.js")"></script>
}










